import {Component} from '@angular/core';
import {NavController} from 'ionic-angular';

import {ProductInfoPage} from './ProductInfo/ProductInfo';

//发送http请求
import {Http,Headers} from '@angular/http';

import 'rxjs/add/operator/toPromise';
import 'rxjs/add/operator/timeout';

@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})

export class HomePage {
	items = [];
	
  //http请求
private headers = new Headers({'Content-Type':'application/json;chartset=utf-8'});
url:string = '../assets/data/list.json';

param = {
    id: "",
};

constructor(public navCtrl: NavController,public http:Http) {
}
goProductInfo() {
    this.navCtrl.push(ProductInfoPage);
}
handleError(err){
console.info(err)
}

/*	home(){
    this.http
        .post(this.url,JSON.stringify(this.param),{headers:this.headers})
        .timeout(5000)
        .toPromise()
        .then((response) => {})
        .catch(this.handleError)
}*/

home(){
this.http.get('../assets/data/list.json')
  .toPromise()
  .then((response) => {
    console.info(response.json().infoData.items)
    this.items = response.json().infoData.items;
  })
  .catch( err => {
    console.log('err');
  })

}

//getRepertoryList		response => response.json()


}
